package by.onlinernews_0_1;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

public class FullNewsFragment extends Fragment {
	static final String ARGUMENT_PAGE_NUMBER = "arg_page_number";
	  
	  int pageNumber;

	  
	  static FullNewsFragment newInstance(int page) {
	    FullNewsFragment FullNewsFragment = new FullNewsFragment();
	    Bundle arguments = new Bundle();
	    arguments.putInt(ARGUMENT_PAGE_NUMBER, page);
	    FullNewsFragment.setArguments(arguments);
	    return FullNewsFragment;
	  }
	  
	  @Override
	  public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    pageNumber = getArguments().getInt(ARGUMENT_PAGE_NUMBER);
	    	     }
	  
	  @Override
	  public View onCreateView(LayoutInflater inflater, ViewGroup container,
	      Bundle savedInstanceState) {
	    View view = inflater.inflate(R.layout.full_news_fragment, null);
	    FullNewsActivity.cursNews.moveToPosition(pageNumber);
	    TextView tvTitle = (TextView) view.findViewById(R.id.tvTitle_news);
	    tvTitle.setText(FullNewsActivity.cursNews
	    		.getString(FullNewsActivity.cursNews
	    				.getColumnIndex(DB.COLUMN_TITLE))); 
	     Button commentButton = (Button) view.findViewById(R.id.btn_comment);


	     commentButton.setOnClickListener(new OnClickListener()
	    {
	        public void onClick(View view)
	        {
	        	CommentsFragment CommentsFragment = new CommentsFragment();
		        FragmentTransaction fTrans = getChildFragmentManager().beginTransaction();
			    fTrans.replace(R.id.frgmCont, CommentsFragment);
			    fTrans.commit();
	        }
	    });
	    
	    return view;
	  }
	  

		
}
